package com.zz.parkingsystem.entity;

import java.io.Serializable;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * 管理员表
 * @TableName t_admin
 */
@Data
public class Admin implements Serializable {
    /**
     * 管理员id
     */
    private Integer adminId;

    /**
     * 部门名字，在service中在转化成id存放
     */
    private Integer deptId;

    /**
     * 登陆电话
     */
    @Pattern(regexp = "^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$",message = "手机号码有误！")
    private String adminTel;

    /**
     * 密码
     */
    @NotBlank(message = "密码不能为空")
    @Size(message = "密码不小于{min}位", min= 8)
    private String adminPassword;

    /**
     * 用户名
     */
    private String adminNickname;

    /**
     * 盐值
     */
    private String adminSalt;

    /**
     * 0:alive 1:dead
     */
    private String adminStatus;

    /**
     * 0:woman 1：man
     */
    private String adminGender;

    /**
     * 用户头像
     */
    private String adminAvatar;

    /**
     * 注册时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date adminCreatedTime;

    /**
     * 修改时间
     */
    private Date adminUpdatedTime;

    /**
     * 预留varchar字段
     */
    private String reservedVar;

    /**
     * 预留int字段
     */
    private Integer reservedInt;

    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Admin other = (Admin) that;
        return (this.getAdminId() == null ? other.getAdminId() == null : this.getAdminId().equals(other.getAdminId()))
            && (this.getDeptId() == null ? other.getDeptId() == null : this.getDeptId().equals(other.getDeptId()))
            && (this.getAdminTel() == null ? other.getAdminTel() == null : this.getAdminTel().equals(other.getAdminTel()))
            && (this.getAdminPassword() == null ? other.getAdminPassword() == null : this.getAdminPassword().equals(other.getAdminPassword()))
            && (this.getAdminNickname() == null ? other.getAdminNickname() == null : this.getAdminNickname().equals(other.getAdminNickname()))
            && (this.getAdminSalt() == null ? other.getAdminSalt() == null : this.getAdminSalt().equals(other.getAdminSalt()))
            && (this.getAdminStatus() == null ? other.getAdminStatus() == null : this.getAdminStatus().equals(other.getAdminStatus()))
            && (this.getAdminGender() == null ? other.getAdminGender() == null : this.getAdminGender().equals(other.getAdminGender()))
            && (this.getAdminAvatar() == null ? other.getAdminAvatar() == null : this.getAdminAvatar().equals(other.getAdminAvatar()))
            && (this.getAdminCreatedTime() == null ? other.getAdminCreatedTime() == null : this.getAdminCreatedTime().equals(other.getAdminCreatedTime()))
            && (this.getAdminUpdatedTime() == null ? other.getAdminUpdatedTime() == null : this.getAdminUpdatedTime().equals(other.getAdminUpdatedTime()))
            && (this.getReservedVar() == null ? other.getReservedVar() == null : this.getReservedVar().equals(other.getReservedVar()))
            && (this.getReservedInt() == null ? other.getReservedInt() == null : this.getReservedInt().equals(other.getReservedInt()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getAdminId() == null) ? 0 : getAdminId().hashCode());
        result = prime * result + ((getDeptId() == null) ? 0 : getDeptId().hashCode());
        result = prime * result + ((getAdminTel() == null) ? 0 : getAdminTel().hashCode());
        result = prime * result + ((getAdminPassword() == null) ? 0 : getAdminPassword().hashCode());
        result = prime * result + ((getAdminNickname() == null) ? 0 : getAdminNickname().hashCode());
        result = prime * result + ((getAdminSalt() == null) ? 0 : getAdminSalt().hashCode());
        result = prime * result + ((getAdminStatus() == null) ? 0 : getAdminStatus().hashCode());
        result = prime * result + ((getAdminGender() == null) ? 0 : getAdminGender().hashCode());
        result = prime * result + ((getAdminAvatar() == null) ? 0 : getAdminAvatar().hashCode());
        result = prime * result + ((getAdminCreatedTime() == null) ? 0 : getAdminCreatedTime().hashCode());
        result = prime * result + ((getAdminUpdatedTime() == null) ? 0 : getAdminUpdatedTime().hashCode());
        result = prime * result + ((getReservedVar() == null) ? 0 : getReservedVar().hashCode());
        result = prime * result + ((getReservedInt() == null) ? 0 : getReservedInt().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", adminId=").append(adminId);
        sb.append(", deptId=").append(deptId);
        sb.append(", adminTel=").append(adminTel);
        sb.append(", adminPassword=").append(adminPassword);
        sb.append(", adminNickname=").append(adminNickname);
        sb.append(", adminSalt=").append(adminSalt);
        sb.append(", adminStatus=").append(adminStatus);
        sb.append(", adminGender=").append(adminGender);
        sb.append(", adminAvatar=").append(adminAvatar);
        sb.append(", adminCreatedTime=").append(adminCreatedTime);
        sb.append(", adminUpdatedTime=").append(adminUpdatedTime);
        sb.append(", reservedVar=").append(reservedVar);
        sb.append(", reservedInt=").append(reservedInt);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}